<template>
  <div v-if="JSON.parse(fieldGlobalShow)">
    <el-form
      :disabled="JSON.parse(!fieldGlobalEdit)"
      ref="elForm"
      :model="formData"
      :rules="rules"
      size="medium"
      label-width="130px"
    >
      <el-form-item
        label="计数器"
        v-if="fieldShow && fieldShow.split(',').includes('code')"
        prop="code"
      >
        <el-input-number
          :disabled="!(fieldEdit && fieldEdit.split(',').includes('code'))"
          v-model="formData.code"
          placeholder="计数器"
          :step="1"
        ></el-input-number>
      </el-form-item>
      <el-form-item
        label="外部流程的输入"
        prop="name"
        v-if="fieldShow && fieldShow.split(',').includes('name')"
      >
        <el-input
          v-model="formData.name"
          :disabled="!(fieldEdit && fieldEdit.split(',').includes('name'))"
          placeholder="请输入外部流程的输入"
          clearable
          :style="{ width: '100%' }"
        >
        </el-input>
      </el-form-item>
      <el-form-item size="large" v-if="btnShow">
        <el-button type="primary" @click="submitForm">提交 </el-button>
        <el-button type="" @click="resetForm">重置 </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  name: "outSide",
  components: {},
  props: {
    fieldGlobalShow: {
      default: () => true,
    },
    fieldGlobalEdit: {
      default: true,
    },
    fieldShow: {
      default: () => "name,code",
    },
    fieldEdit: {
      default: () => "name,code",
    },
    btnShow: {
      default: () => true,
    },
    // extensionMap: {
    //   type: Object,
    //   default: {
    //     ...setDefalutProps("name,code", "pass,assign,transfer,return,refuse"),
    //   },
    // },
  },
  data() {
    return {
      formData: {
        code: undefined,
        name: undefined,
      },
      rules: {
        code: [
          {
            required: true,
            message: "计数器",
            trigger: "blur",
          },
        ],
        name: [
          {
            required: true,
            message: "请输入外部流程的输入",
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        // TODO 提交表单
        const params = {
          valData: this.formData,
        };
        this.$emit("submit", params);
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
  },
};
</script>
